package com.ruoyi.equip.vert.constant;

import com.ruoyi.equip.vert.service.impl.*;
import com.ruoyi.equip.vert.service.TransferStrategy;

import static com.ruoyi.equip.vert.TcpReaderConstant.*;

public enum TransferEnum {
    /**
     * 请求标签列表
     */
    TAG_INFO(REQ_TAG_NUM, new ReqTagNumTransfer()),

    /**
     * 请求标签信息
     */
    //TAG_INFO(REQ_TAG_INFO, new ReqTagInfoTransfer()),
    //CONFIG_MODE(ANS_CONFIG_MODE, new ConfigModeTransfer()),
    REPORT_DATA(DATA, new DataTransfer()),

    HEART_DATA(HEART,new HeartTransfer())


    ;

    private String codeKey;
    private TransferStrategy transferStrategy;

    public String getCodeKey() {
        return codeKey;
    }

    public void setCodeKey(String codeKey) {
        this.codeKey = codeKey;
    }

    public TransferStrategy getTransferStrategy() {
        return transferStrategy;
    }

    public void setTransferStrategy(TransferStrategy transferStrategy) {
        this.transferStrategy = transferStrategy;
    }

    TransferEnum(String codeKey, TransferStrategy transferStrategy) {
        this.codeKey = codeKey;
        this.transferStrategy = transferStrategy;
    }

    public static TransferStrategy getStrategyClass(String cmdCode) {
        for (TransferEnum command : TransferEnum.values()) {
            if (command.getCodeKey().equals(cmdCode)) {
                return command.getTransferStrategy();
            }
        }
        return null; // 如果找不到对应的 cmdCode，则返回 null 或者其他默认值
    }

}
